#include "dllDemo.h"
#include <windows.h>
typedef struct{
	char words[10];
}keywords;

typedef struct{
	keywords *kws;
	unsigned int len;
}outStruct;

extern "C" _declspec(dllexport)int Sum(int a, int b)
{
	return a+b;
}
extern "C" _declspec(dllexport)int Max(int a, int b)
{
	if(a>=b)
		return a;
	else
		return b;
}
extern "C" _declspec(dllexport)int Min(int a, int b)
{
	if(a>=b)
		return b;
	else
		return a;
}

extern "C" int __declspec(dllexport) testStruct(outStruct *o)
{
	unsigned int i = 4;
	o->kws = (keywords *)malloc(sizeof(unsigned char)*10*i);
	strcpy(o->kws[0].words, "The First Data");
	strcpy(o->kws[1].words, "The Second Data");
	o->len = i;

	return 1;
}

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )              
{
	switch (ul_reason_for_call)
	{    
	case DLL_PROCESS_ATTACH:    
		OutputDebugString(TEXT("\nprocess attach of dll"));
		break;
	case DLL_THREAD_ATTACH:    
		OutputDebugString(TEXT("\nthread attach of dll"));
		break;
	case DLL_THREAD_DETACH:    
		OutputDebugString(TEXT("\nthread detach of dll"));
		break;
	case DLL_PROCESS_DETACH:    
		OutputDebugString(TEXT("\nprocess detach of dll"));
		break;    
	}
	return TRUE;    
}